module PhotosHelper
  def display_photo(photo, thumbnail = false, container = nil)
    link_to(
      image_tag(
        photo.path(thumbnail),
        :class  => "#{thumbnail ? "thumbnail" : "photo"}",
        :alt    => h(photo.caption.to_s),
        :style  => "#{"max-width: 350px;" if !thumbnail}" ),
      photo.path,
      :rel    => lightbox_container_name(container),
      :pid    => photo.id,
      :title  => h(photo.caption.to_s)
    )
  end
  
  def lightbox_container_name container
    if container.blank?
      ""
    else
      name = 
        if String === container 
          container
        else
          "#{container.class.to_s}-#{container.id.to_i}"
        end
      name = "lightbox[#{name}]"
    end
  end
end
